package com.example.xpvideo.Controller;

import com.example.xpvideo.entity.LsSeckillGoods;
import com.example.xpvideo.entity.LsSeckillTime;
import com.example.xpvideo.entity.PageResult;
import com.example.xpvideo.entity.ResponseResult;
import com.example.xpvideo.entity.req.*;
import com.example.xpvideo.entity.res.PhpVideoRes;
import com.example.xpvideo.entity.res.SeckillGoodsDetail;
import com.example.xpvideo.entity.res.SeckillGoodsRes;
import com.example.xpvideo.service.SeckillGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("/back/seckill")
public class SeckillGoodsController {
    @Autowired
    private SeckillGoodsService seckillGoodsService;

    @GetMapping("/list")
    public ResponseResult<PageResult<List<SeckillGoodsRes>>> list(SecckillGoodsReq secckillGoodsReq)
            throws Exception{
        return seckillGoodsService.list(secckillGoodsReq);
    }

    @GetMapping("/detail")
    public ResponseResult<SeckillGoodsDetail> detail(Integer id)
            throws Exception{
        return seckillGoodsService.detail(id);
    }

    @PostMapping("/insertime")
    public ResponseResult<Object> insertTime(@RequestBody @NotNull InsertSeckillTime insertSeckillTime) throws Exception{
        return seckillGoodsService.insertTime(insertSeckillTime);
    }

    @PostMapping("/deletetime")
    public ResponseResult<Object> deleteTime(@RequestBody @NotNull
                                             UpdateReq updateReq) throws Exception{
        return seckillGoodsService.deleteTime(updateReq);
    }

    @GetMapping("/timelist")
    public ResponseResult<PageResult<List<LsSeckillTime>>> timeList()throws Exception{
        return seckillGoodsService.timeList();
    }

    @PostMapping("/update")
    public ResponseResult<Object> update(@RequestBody LsSeckillGoods lsSeckillGoods) throws Exception{
        return seckillGoodsService.update(lsSeckillGoods);
    }

    @PostMapping("/delete")
    public ResponseResult<Object>delete(@RequestBody @NotNull UpdateReq updateReq) throws Exception{
        return seckillGoodsService.delete(updateReq);
    }

    @PostMapping("/audit")
    public ResponseResult<Object> audit(@RequestBody @NotNull AuditReq auditReq) throws Exception{
        return seckillGoodsService.audit(auditReq);
    }
}
